#include "login.h"
#include "ui_login.h"

login::login(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::login)
{
    ui->setupUi(this);
    this->setWindowModality(Qt::ApplicationModal);
    ui->label_5->setPixmap(QPixmap(":/image/IMG_7841(20220928-172509).JPG"));
    ui->label_5->setScaledContents(true);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);

    easyInput *eInput =new easyInput(this);//输入法实例化
    eInput->installEventFilter(this);//安装事件过滤器
    this->setFocus();
}

login::~login()
{
    delete ui;
}

void login::paintEvent(QPaintEvent *event)
{
        QStyleOption opt;
        opt.init(this);
        QPainter p(this);
        style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
        p.drawPixmap(0,0,this->width(),this->height(),QPixmap(":/image/1_210414101157_1.JPG"));
}



void login::on_login_button_clicked()
{
    if(ui->lineEdit->text().isEmpty() || ui->lineEdit_2->text().isEmpty()){
      QMessageBox::information(this, tr("提示"),tr("请输入账号和密码!"), QMessageBox::Ok);
    }
    else{
        if(ui->lineEdit->text() == "admin" && ui->lineEdit_2->text() == "123"){
                this->close();
        }
        else{
            QMessageBox::information(this, tr("提示"),tr("账号或密码错误!"), QMessageBox::Ok);
        }
    }
}
